# Importing Data
SAUDI<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "AC1:AC239")

# Checking the Imported Data
View(SAUDI)
# Creating Time Series Data
Saudi_ts <- ts(SAUDI, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
Saudi_ts
sum(is.na(Saudi_ts))
library(forecast)
Saudi_ts <- tsclean(Saudi_ts)
Saudi_ts

# Identification: Plotting the Time Series Data
plot(Saudi_ts)

# Estimating the appropriate model
Saudi_ts_model <- auto.arima(Saudi_ts)
Saudi_ts_model

# Forecasting
options(max.print=1000000)
Saudi_ts_forecast <- forecast (Saudi_ts_model, level=c(95), h=255)
plot(Saudi_ts_forecast)
Saudi_ts_forecast             

# Exporting
write.table(Saudi_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/SAUDI_TSA.csv", sep=",")
